
package horde.minefield.andres;

import horde.control.DummyBehavior;
import horde.interfaces.Requests;
import horde.patterns.Agent;
import horde.patterns.Msg;
import horde.patterns.master.MasterAgent;

/**
 * @author Andres
 */
public class smithTest {

    public static void test () {
        MasterAgent the_architect = new MasterAgent("Architect");
        Requests requestLink = Requests.createRequests(the_architect);
        agentSmithCoreTest smithCore = new agentSmithCoreTest();
        DummyBehavior dummy = new DummyBehavior(smithCore);
        Agent smith = new Agent ("Smith", dummy, smithCore, requestLink);
        the_architect.addAgent(smith);
        /* Test message */
        Msg sayHi = new Msg ("Tester", "Smith", Msg.TYPE_REQUEST, "sayHi");
        the_architect.sendMessage(sayHi);
        System.err.println ("Starting agents...");
        /* Start the gunfire */
        the_architect.startAgents();
        System.err.println ("Running " + the_architect.getNumberOfAgentsRunning() + " agents");
        try {
            System.out.println ("Stopping for a couple seconds...");
            Thread.sleep(2000);
        } catch (Exception e) {
            System.err.println ("Failure stopping main thread");
        }
        /* Politely request smith to stop messing around */
        the_architect.stopAgents();
    }

}
